package com.example.helloworld;

import com.example.helloworld.tools.Tools;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

	
public class MySQLliteHelper extends SQLiteOpenHelper {
	 // All Static variables
    // Database Version
    private static final int DATABASE_VERSION = 1;
 
    // Database Name
    private static final String DATABASE_NAME = "contactsManager";
	
    
    //TODO if not exists
    private static final String TABLE_ITEMS = "create table " + Tools.DBTableItems.TABLE// + " if not exists "
			+ "("
			+ Tools.DBTableItems.ID + " integer primary key autoincrement, "
			+ Tools.DBTableItems.TITLE + " text not null default '', "
			+ Tools.DBTableItems.STATUS + " text not null default '', "
			+ Tools.DBTableItems.PRICE + " integer not null default 0, "
			+ Tools.DBTableItems.SECTION + " integer not null"
			+ " )";
	
	private static final String TABLE_SECTION = "create table " + Tools.DBTableSections.TABLE+ " ("
			+ Tools.DBTableSections.ID + " integer primary key autoincrement, "
			
			+ Tools.DBTableSections.TITLE + " text not null default ''"
			+ " )";
	
	public MySQLliteHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		Tools.print("onCreate " + getClass());
		db.execSQL(TABLE_ITEMS);
		db.execSQL(TABLE_SECTION);
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub

	}

}
